package cn.middle.remote.message;

import java.util.UUID;

public abstract class BaseSignal implements Signal{

	/*
	 * 消息类型
	 */
	private byte msgType;
	
	/*
	 * *
	 * 消息ID
	 */
	private String id;
		
	protected BaseSignal(byte msgType) {
		this.msgType = msgType;
	}
	
	@Override
	public byte getMessageType() {
		return msgType;
	}
	
	@Override
	public String getId() {
		if(id == null) { //如果为空，生成一个UUID
			id = UUID.randomUUID().toString();
		}
		return id;
	}
	
	@Override
	public void setId(String id) {
		this.id = id;
	}
	
	
	public abstract byte[] toData();

}
